#!/usr/bin/env bash
base_path=~/docker/ELK/kafka/
container_name=elk-kafka
port1=9092
port2=9093
script_pwd=$(dirname "$0")

rm -rf $base_path/config

mkdir -p $base_path/config
mkdir -p $base_path/data
mkdir -p $base_path/logs

cp -r $script_pwd/config/server.properties $base_path/config/.
cp -r $script_pwd/config/log4j.properties $base_path/config/.

docker rm -f $container_name

docker run -itd \
--name $container_name \
-e KAFKA_HEAP_OPTS=" -Xms1g -Xmx1g " \
-e TZ=Asia/Shanghai \
-p $port1:9092 \
-p $port2:9093 \
-v $base_path/config:/mnt/shared/config \
-v $base_path/data:/opt/kafka/data \
-v $base_path/logs:/opt/kafka/logs \
apache/kafka:3.9.0
